package com.igeek.boot.controller;

import com.igeek.boot.entity.User;
import com.igeek.boot.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author fengqq
 * @Description TODO
 * @Date 2024/8/21  14:52
 */
@RestController
@Slf4j
public class LogController {

    @GetMapping("/log")
    public String log(int id){
        try{
            int x = 10/id;
            log.debug("debug----id="+id);
            log.info("info----id="+id);
            log.warn("warn----id="+id);
        }catch (Exception e){
            e.printStackTrace();
            log.error("id为零了~~~");
        }
       return "ok";
    }

    @Autowired
    private UserMapper userMapper;
    @GetMapping("/{id}")
    public User findOne(@PathVariable("id") int id){
        return userMapper.selectByPrimaryKey(id);
    }
}
